<template>
  <div class="pageBox">
    <div class="top">
      <div class="topBg"></div>
      <div class="topMain" v-if="info">
        <img class="avator" :src="info.avatar" alt="" />
        <div class="mainBox">
          <div class="nickname flex-center">
            <p>{{ info.nickname }}</p>
            <span class="flex-row"
              >{{ info.account
              }}<span class="level">等级：{{ info.LevelName }}</span></span
            >
          </div>
          <div class="partner flex-center" v-if="info.serviceLevelName">
            {{ info.serviceLevelName }}
          </div>
          <div class="mainBoxMenu flex-between">
            <div
              class="mainBoxMenuItem flex-center"
              @click="goPage('/bean', info.frozenScore)"
            >
              <p>{{ info.frozenScore }}</p>
              <span>福豆</span>
            </div>
            <div
              class="mainBoxMenuItem flex-center"
              @click="goPage('/integral', info.score)"
            >
              <p>{{ info.score }}</p>
              <span>金豆</span>
            </div>
            <div
              class="mainBoxMenuItem flex-center"
              @click="goPage('/shareOutBonus', info.bonus, info.place_id)"
            >
              <p>{{ info.bonus }}</p>
              <span>爱心值</span>
            </div>
            <div
              class="mainBoxMenuItem flex-center"
              @click="goPage('/safe', info.safety)"
            >
              <p>{{ info.safety }}</p>
              <span>安全仓</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="orderBox">
      <div class="order flex-between">
        <div class="orderLeft">我的订单</div>
        <div class="orderRight flex-row" @click="goOrder(0)">
          <p>全部订单</p>
          <img src="@/image/my/youjiantou1_btn.png" alt="" />
        </div>
      </div>
      <div class="orderList flex-between">
        <div class="orderListItem flex-center" @click="goOrder(1)">
          <img src="@/image/my/daizhifu_btn.png" alt="" />
          <p>待付款</p>
          <div class="amount flex-center">{{ info.orderPaymentNum }}</div>
        </div>

        <div class="orderListItem flex-center" @click="goOrder(2)">
          <img src="@/image/my/daifahuo_btn.png" alt="" />
          <p>待发货</p>
          <div class="amount flex-center">{{ info.orderShippedNum }}</div>
        </div>

        <div class="orderListItem flex-center" @click="goOrder(3)">
          <img src="@/image/my/daishou_btn.png" alt="" />
          <p>待收货</p>
          <div class="amount flex-center">{{ info.orderReceivedNum }}</div>
        </div>

        <div class="orderListItem flex-center" @click="goOrder(5)">
          <img src="@/image/my/yiwancehng_btn.png" alt="" />
          <p>已完成</p>
        </div>
      </div>
    </div>

    <div class="commonly">
      <div class="commonlyTitle">常用功能</div>
      <div class="menu">
        <div class="menuItem flex-between" @click="goPage('/team')">
          <div class="menuItemLeft flex-row">
            <img src="@/image/my/liuyanfankui_btn.png" alt="" />
            <p>我的团队</p>
          </div>
          <img
            class="menuItemRight"
            src="@/image/my/youjiantou1_btn.png"
            alt=""
          />
        </div>

        <div class="menuItem flex-between" @click="goPage('/myAddr')">
          <div class="menuItemLeft flex-row">
            <img src="@/image/my/tuiguanghaibao_btn.png" alt="" />
            <p>收货地址</p>
          </div>
          <img
            class="menuItemRight"
            src="@/image/my/youjiantou1_btn.png"
            alt=""
          />
        </div>

        <div class="menuItem flex-between" @click="goPage('/regionalMap')">
          <div class="menuItemLeft flex-row">
            <img src="@/image/my/quyuditu_btn.png" alt="" />
            <p>区域地图</p>
          </div>
          <img
            class="menuItemRight"
            src="@/image/my/youjiantou1_btn.png"
            alt=""
          />
        </div>

        <div class="menuItem flex-between" @click="goPage('/share')">
          <div class="menuItemLeft flex-row">
            <img src="@/image/my/wodedizhi_btn.png" alt="" />
            <p>邀请好友</p>
          </div>
          <img
            class="menuItemRight"
            src="@/image/my/youjiantou1_btn.png"
            alt=""
          />
        </div>

        <div class="menuItem flex-between" @click="goPage('/setting')">
          <div class="menuItemLeft flex-row">
            <img src="@/image/my/shezhi_btn.png" alt="" />
            <p>个人设置</p>
          </div>
          <img
            class="menuItemRight"
            src="@/image/my/youjiantou1_btn.png"
            alt=""
          />
        </div>
      </div>
    </div>

    <button class="signOut" @click="onSignOut">退出登录</button>

    <foot-component tab="4"></foot-component>
  </div>
</template>

<script type="text/ecmascript-6">
import { Dialog } from "vant";
import { defineComponent, ref } from "vue";
import footComponent from "../../components/footComponent.vue";
import router from "../../router";
import { post } from "../../untils/request";

export default defineComponent({
  components: {
    footComponent,
  },
  setup() {
    const info = ref({});

    function getInfo() {
      post("/portal", {
        loading: true,
        module: "User",
        interface: "1000",
      }).then((res) => {
        info.value = res.data;
        console.log(info.value,"个人信息");
      });
    }
    getInfo();

    function goPage(url, balance, placeId) {
      router.push({
        path: url,
        query: {
          balance: balance,
          placeId: placeId,
        },
      });
    }

    function goOrder(type) {
      router.push({
        path: "/order",
        query: {
          type: type,
        },
      });
    }

    function onSignOut() {
      Dialog.confirm({
        title: "提示",
        message: "确定退出登录？",
      })
        .then(() => {
          localStorage.removeItem("token");
          router.replace({
            path: "/login",
          });
        })
        .catch(() => {
          // on cancel
        });
    }

    return {
      info,
      goPage,
      goOrder,
      onSignOut,
      getInfo,
    };
  },
});
</script>

<style scoped lang="less">
.pageBox {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 176px;
  .top {
    width: 100%;
    height: 555px;
    position: relative;
    padding-top: 195px;
    .topBg {
      width: 100%;
      height: 370px;
      position: absolute;
      top: 0;
      left: 0;
      background: linear-gradient(180deg, #b30b11 0%, #f50811 100%);
      border-radius: 0 0 20% 20%;
      z-index: 1;
    }
    .topMain {
      width: 92%;
      height: 427px;
      margin: 0 auto;
      position: relative;
      .avator {
        width: 130px;
        height: 130px;
        border-radius: 50%;
        position: absolute;
        top: -65px;
        left: 50%;
        transform: translate(-50%);
        z-index: 3;
      }
      .mainBox {
        width: 100%;
        height: 360px;
        background: #ffffff;
        box-shadow: 0px 4px 10px 0px rgba(219, 204, 205, 0.26);
        border-radius: 28px;
        z-index: 2;
        position: relative;
        padding-top: 70px;
        .nickname {
          flex-direction: column;
          p {
            font-size: 32px;
            font-weight: 500;
            color: #333333;
          }
          span {
            font-size: 24px;
            font-weight: 400;
            color: #666666;
            .level {
              color: #e00b12;
              font-size: 26px;
              margin-left: 20px;
              padding-left: 20px;
              border-left: 2px solid #999999;
            }
          }
        }
        .partner {
          font-size: 24px;
          font-weight: 400;
          // width: 160px;
          // height: 64px;
          background: linear-gradient(138deg, #8655dc 0%, #c571d9 100%);
          border-radius: 100px 0px 0px 100px;
          color: #f5f5f5;
          position: absolute;
          right: 0;
          top: 76px;
          padding: 14px 20px;
        }
        .mainBoxMenu {
          margin-top: 59px;
          padding: 0;

          .mainBoxMenuItem {
            flex-direction: column;
            width: 25%;
            text-align: center;

            p {
              font-size: 40px;
              font-weight: 500;
              color: #333333;
              margin-bottom: 2px;
              overflow: auto;
              width: 100%;

              &::-webkit-scrollbar {
                display: none;
              }
            }

            span {
              font-size: 24px;
              font-weight: 400;
              color: #999999;
            }
          }
        }
      }
    }
  }
  .orderBox {
    width: 92%;
    // height: 310px;
    background: #ffffff;
    box-shadow: 0px 4px 10px 0px rgba(219, 204, 205, 0.26),
      0px 8px 16px 0px rgba(223, 207, 207, 0.5);
    border-radius: 16px;
    margin: 30px auto 0;
    padding: 40px 21px 40px 26px;
    .order {
      .orderLeft {
        font-size: 32px;
        font-weight: 500;
        color: #2e3033;
      }
      .orderRight {
        p {
          font-size: 28px;
          font-weight: 400;
          color: #999999;
          margin-right: 5px;
        }
        img {
          width: 28px;
          height: 28px;
        }
      }
    }
    .orderList {
      padding: 0 30px;
      margin-top: 40px;
      .orderListItem {
        flex-direction: column;
        position: relative;
        img {
          width: 88px;
          height: 88px;
        }
        p {
          font-size: 26px;
          font-weight: 400;
          color: #616366;
          margin-top: 20px;
        }
        .amount {
          color: #ffffff;
          font-size: 24px;
          background-color: #f50811;
          position: absolute;
          right: 10px;
          top: 78px;
          border-radius: 16px;
          padding: 0 4px;
        }
      }
    }
  }
  .commonly {
    padding: 40px 20px 45px 24px;
    width: 92%;
    background: #ffffff;
    box-shadow: 0px 8px 16px 0px rgba(223, 207, 207, 0.5);
    border-radius: 16px;
    margin: 30px auto 0;
    .commonlyTitle {
      font-size: 32px;
      font-weight: 500;
      color: #2e3033;
    }
    .menu {
      .menuItem {
        margin-top: 40px;
        .menuItemLeft {
          img {
            width: 40px;
            height: 40px;
          }
          p {
            font-size: 28px;
            font-weight: 400;
            color: #4d4d4d;
            padding-left: 20px;
          }
        }
        .menuItemRight {
          width: 30px;
          height: 30px;
        }
      }
    }
  }
  .signOut {
    width: 92%;
    font-size: 32px;
    font-weight: 400;
    color: #ffffff;
    height: 88px;
    background: linear-gradient(270deg, #b30b11 0%, #f50811 100%);
    border-radius: 16px;
    margin: 50px auto 0;
    display: block;
    border: none;
  }
}
</style>